home *** CD-ROM | disk | FTP | other *** search
- /*
- ** READS.C [edit EMAIL.H before compiling]
- **
- ** This program reads all email message
- ** and saves them to disk.
- */
-
- #include <windows.h>
- #include <stdio.h>
- #include <stdlib.h>
- #include "see.h"
- #include "email.h"
-
- #define QUOTE 0x22
-
- static char Buffer[1024];
-
- void ErrorExit(int Code)
- {seeErrorText(Code,(LPSTR)Buffer,512);
- printf("SEE Error %d: %s\n", Code, Buffer);
- seeClose();
- exit(1);
- }
-
- void main(void)
- {int i, Code;
- int Version;
- int Count;
- int MsgNbr;
- long MsgSize;
- long BytesRead;
- static char Filename[65];
-
- /* display parameters */
-
- Version = seeStatistics(SEE_GET_VERSION);
- printf("SEE4C Version %1x.%1x.%1x\n",0x0f&(Version>>8),0x0f&(Version>>4),0x0f&Version);
- printf("Server : %s\n",(LPSTR)POP3_HOST_NAME);
- printf(" User : %s\n",(LPSTR)POP3_USER_NAME);
- printf(" Pass : %s\n",(LPSTR)POP3_PASSWORD);
-
- /* define diagnostics log file */
- ///seeStringParam(SEE_LOG_FILE, (LPSTR)"reader.log");
- /* connect to POP3 server */
- puts("Connecting...");
- Code = seePop3Connect(
- (LPSTR)POP3_HOST_NAME, /* POP3 server */
- (LPSTR)POP3_USER_NAME, /* user */
- (LPSTR)POP3_PASSWORD); /* Password */
- if(Code<0) ErrorExit(Code);
- /* get # messages waiting */
- puts("Getting message count...");
- Count = seeGetEmailCount();
- if(Count<0) ErrorExit(Count);
- printf("%d messages waiting.\n", Count);
- /* any email waiting ? */
- if(Count==0)
- {printf("No messages waiting\n");
- seeClose();
- exit(1);
- }
- /* read email messages */
- for(MsgNbr=1;MsgNbr<=Count;MsgNbr++)
- {/* read message */
- MsgSize = seeGetEmailSize(MsgNbr);
- if(MsgSize<0) ErrorExit((int)MsgSize);
- /////printf("Message %d has %ld bytes\n", MsgNbr, MsgSize);
- /* turn off AUTO CALL driver */
- seeIntegerParam(SEE_AUTO_CALL_DRIVER, 0);
- /////printf("Reading message %d...\n",MsgNbr);
- /* construct filename */
- wsprintf((LPSTR)Filename,(LPSTR)"email%1d.mai",MsgNbr);
- printf("Saving message %d to '%s'\n", MsgNbr, Filename);
- /////Code = seeGetEmailFile(MsgNbr, Filename, "c:\\temp", "c:\\temp");
- Code = seeGetEmailFile(MsgNbr, Filename, ".", ".");
- if(Code<0) ErrorExit(Code);
- /* run the driver */
- for(i=0;;i++)
- {Code = seeDriver();
- if(Code<0) ErrorExit(Code);
- if(((i%10)==9)||(Code==0))
- {/* display progress on last call & every 10th call to seeDriver() */
- BytesRead = (long) seeStatistics(SEE_GET_TOTAL_BYTES_READ);
- printf("%ld bytes read.\r",BytesRead);
- }
- if(Code==0) break;
- }
- printf("\n");
- /* turn AUTO CALL back on for seeClose */
- seeIntegerParam(SEE_AUTO_CALL_DRIVER, 1);
- if(Code<0) ErrorExit(Code);
- }
- seeClose();
- } /* end main */
-
-
-